#!/usr/bin/env python
# encoding: utf-8
"""
exceptions.py

Created by Bud Gibson on 2010-08-03.
Copyright (c) 2010 Bud Gibson. Available under the GPL/Artistic License.
"""

class HttpError(Exception):
  """Raised whenever an http error is encountered in the response headers"""
  def __init__(self, status, reason, url):
    super(HttpError, self).__init__()
    self.status = status
    self.reason = reason
    self.url = url
  
  def __str__(self):
    """redefining string so an informative error message will appear"""
    return str(self.status) + ' ' + self.reason + ' when accessing: ' +\
      self.url
    

def main():
	try:
	  raise HttpError(503, 'service unavailable', 'http://budgibson.com')
	except HttpError as mistake:
	  print mistake


if __name__ == '__main__':
	main()

